package com.thinkfit.jy.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.thinkfit.jy.R;


public class ToastUtils {

    private static ToastUtils toastUtils;


    public static ToastUtils getInstance(){
        if(toastUtils == null){
            toastUtils = new ToastUtils();
        }
        return toastUtils;
    }

    public void show(Context context,String msg){
//        Toast toast = Toast.makeText(context,msg, Toast.LENGTH_SHORT);
//        toast.setGravity(Gravity.CENTER, 0, 0);
//        toast.show();
        View inflater = LayoutInflater.from(context).inflate(R.layout.item_toast, null);
        TextView tvToast = inflater.findViewById(R.id.tv_toast);
        tvToast.setText(msg+"");
        Toast toast= new Toast(context);
        toast.setGravity(Gravity.CENTER , 0, 0);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.setView(inflater);
        toast.show();

    }

}
